package com.lin.subject.infra.basic.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lin.subject.commom.enums.IsDeletedFlagEnum;
import com.lin.subject.infra.basic.entity.SubjectBrief;
import com.lin.subject.infra.basic.entity.SubjectJudge;
import com.lin.subject.infra.basic.service.SubjectJudgeService;
import com.lin.subject.infra.basic.mapper.SubjectJudgeDao;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
* @author jeremylin
* @description 针对表【subject_judge(判断题)】的数据库操作Service实现
* @createDate 2024-10-21 11:12:13
*/
@Service
public class SubjectJudgeServiceImpl extends ServiceImpl<SubjectJudgeDao, SubjectJudge>
    implements SubjectJudgeService{


    @Override
    public void insertOne(SubjectJudge subjectJudge) {
        save(subjectJudge);
    }

    @Override
    public List<SubjectJudge> queryByCondition(SubjectJudge subjectJudge) {
        return lambdaQuery()
                .eq(Objects.nonNull(subjectJudge.getSubjectId()),
                        SubjectJudge::getSubjectId,
                        subjectJudge.getSubjectId())
                .list();
    }

    @Override
    public void deleteSubject(Long id) {
        UpdateWrapper<SubjectJudge> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda().set(SubjectJudge::getIsDeleted, IsDeletedFlagEnum.DELETED.getCode())
                .eq(SubjectJudge::getSubjectId, id);

        this.update(updateWrapper);
    }
}




